<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:th="http://www.thymeleaf.org"
      xmlns:layout="http://www.w3.org/1999/xhtml"
      layout:decorator="inc/layout"
>
<head>
    <meta charset="UTF-8"/>
    <title>课程类型</title>
    <script>

        function editCourseType(id) {
            layer.open({
                type: 2,
                title: '修改',
                shadeClose: true,
                shade: 0.8,
                area: ['420px', '320px'],
                content: ctxPath+'courseType/edit?id=' + id, //iframe的url
                end: function () {
                    location.reload();
                }
            })
        }

        function deleteCourseType(id) {
            layer.confirm('确定要删除该课程类型吗？', {
                btn: ['确定', '取消']
            }, function () {
                $.post(ctxPath+"courseType/delete",{id:id},function (data) {
                    layer.alert(data,function () {
                        location.reload();
                    });

                })

            });
        }
        function addCourseType() {
            layer.open({
                type: 2,
                title: '修改',
                shadeClose: true,
                shade: 0.8,
                area: ['420px', '320px'],
                content: ctxPath+'courseType/add', //iframe的url
                end: function () {
                    location.reload();
                }
            })
        }

    </script>

</head>
<body>


<div class="container" layout:fragment="content">
    <button  class="btn btn-sm btn-primary pull-right" onclick="addCourseType()">添加</button>

    <table class="table table-bordered  table-hover" style="margin-top: 50px">
        <thead>
        <tr class="success">
            <td th:width="40">id</td>
            <td >name</td>
            <td >描述</td>

            <td th:width="110">编辑</td>

        </tr>
        </thead>
        <tbody>

        <tr th:each="t:${courseTypes}">
            <td th:text="${t.id}"></td>
            <td th:width="100" th:text="${t.name}"></td>
            <td th:text="${t.description}"></td>
            <td>
                <span  style="cursor: pointer">
                    <span class="btn-primary btn-sm" th:onclick="'editCourseType(' + ${t.id} + ')'">编辑</span>
                    <span class="btn-primary btn-sm" th:onclick="'deleteCourseType(' + ${t.id} + ')'">删除</span>
                </span>
            </td>
        </tr>
        </tbody>

    </table>




</div>


</body>
</html>